<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <script src="/libs/react.development.js"></script>
    <script src="/libs/react-dom.development.js"></script>
    <script src="/libs/babel.min.js"></script>
    <title>Document</title>
  </head>

  <body>
    <div id="root"></div>
    <script type="text/babel">
      class Login extends React.Component {
        handleSubmit = (event) => {
          event.preventDefault();
          alert(`${this.username.value},${this.password.value}`);
        };

        render() {
          return (
            <div>
              <form onSubmit={this.handleSubmit}>
                <input
                  ref={(c) => {
                    this.username = c;
                  }}
                  type="text"
                  name="username"
                />
                <input
                  ref={(c) => {
                    this.password = c;
                  }}
                  type="text"
                  name="password"
                />
                <button type="submit">登录</button>
              </form>
            </div>
          );
        }
      }
      ReactDOM.render(<Login />, document.getElementById("root"));
    </script>
  </body>
</html>
